<!DOCTYPE html>
<html lang="ch-ZN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="css/all.css">
</head>
<body>
<div>
<label>
    <input type="checkbox" name="quux[1]" disabled>
    Foo
</label>

<label for="baz[1]">Bar</label>
<input type="checkbox" name="quux[2]" id="baz[1]" checked value="1">

<label for="baz[2]">Bar</label>
<input type="checkbox" name="quux[2]" id="baz[2]" value="2">
</div>
<div>
<button id="check">全选</button>
<button id="uncheck">全不选</button>
<button id="getValue">获取值</button>
    <input type="checkbox" id="allOptionId" value="all"/>
</div>

<script src="js/jquery-1.11.3.js"></script>
<script src="js/icheck.js"></script>
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_flat-blue', //每个风格都对应一个，这个不能写错哈。
            radioClass: 'icheckbox_flat-blue',
        });
        $('#check').on('click', function () {
            $('input').iCheck('check');
        })
        $('#uncheck').on('click', function () {
            $('input').iCheck('uncheck');
        })

        $('#allOptionId').on('ifChecked', function(event){
            $('input').iCheck('check');
        });

        $('#allOptionId').on('ifUnchecked', function(event){
            $('input').iCheck('uncheck');
        });

        $('#getValue').on('click',function(){
            var checkBoxArr = [];
            $('input[name="quux[2]"]:checked').each(function() {
                checkBoxArr.push($(this).val());
            });
            console.log(checkBoxArr.toString())
        })
    })
</script>
</body>
</html>
